package com.zcs.app.wisdomschool.ui;

import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.greateffect.littlebud.lib.base.BaseNormalActivityAdv;
import com.greateffect.littlebud.lib.cache.CustomExtraKeys;
import com.greateffect.littlebud.lib.imageloader.ImageLoader;
import com.greateffect.littlebud.lib.provider.PicProvider;
import com.greateffect.littlebud.lib.utils.GlideStaticUtils;
import com.zcs.app.wisdomschool.R;
import com.zcs.app.wisdomschool.bean.EvaluateBean;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;

import java.util.Random;

/**
 * Created by ZengCS on 2019/1/18.
 * E-mail:zengcs@vip.qq.com
 * Add:成都市天府软件园E3
 */
@EActivity(R.layout.activity_apply_detail)
public class ApplyDetailActivity extends BaseNormalActivityAdv {
    @Extra(CustomExtraKeys.KEY_SERIALIZABLE_BEAN)
    EvaluateBean mEvaluateBean;

//    @ViewById(R.id.id_iv_apply_top)
//    ImageView ivTop;
    @ViewById(R.id.id_tv_desc)
    TextView tvDesc;
    @ViewById(R.id.id_iv_empty)
    ImageView ivEmpty;
    @ViewById(R.id.id_tv_empty)
    TextView tvEmpty;
    @ViewById(R.id.id_tv_evaluate_name)
    TextView tvName;

    @AfterViews
    void init() {
        if (mEvaluateBean == null) {
            showExitMessageDialog("数据异常");
            return;
        }
        tvName.setText(mEvaluateBean.getName());
        // GlideStaticUtils.displayImage(mEvaluateBean.getPic(), R.drawable.empty_photo, ivTop);
        String desc = mEvaluateBean.getDesc();
        boolean hasDesc = !TextUtils.isEmpty(desc);
        tvDesc.setText(desc);
        tvDesc.setVisibility(hasDesc ? View.VISIBLE : View.GONE);
        ivEmpty.setVisibility(!hasDesc ? View.VISIBLE : View.GONE);
        tvEmpty.setVisibility(!hasDesc ? View.VISIBLE : View.GONE);
    }

    // 处理点击事件
    @Click({
            R.id.id_iv_custom_toolbar_back,
            R.id.id_btn_apply,
            R.id.id_btn_share,
    })
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.id_btn_share:
                showToast("分享");
                break;
            case R.id.id_btn_apply:
                openApplyInputActivity();
                break;
            case R.id.id_iv_custom_toolbar_back:
                onBackPressed();
                break;
        }
    }

    private void openApplyInputActivity() {
        Intent intent = new Intent(this, ApplyInputActivity_.class);
        intent.putExtra(CustomExtraKeys.KEY_SERIALIZABLE_BEAN, mEvaluateBean);
        launchActivity(intent);
    }
}
